#ifndef JS_TREE_H
#define JS_TREE_H

enum jstree_index {
    JSTREE_IDX___INIT__,
    JSTREE_IDX_ENTRYPOINT,
    JSTREE_IDX_ABORT,
    JSTREE_IDX_NOP,
    JSTREE_IDX_THIS,
    JSTREE_IDX_IPTR_TYPE,
    /* types */
    JSTREE_IDX_OBJECT,
    JSTREE_IDX_OBJECT_REF,
    JSTREE_IDX_INTOBJECT,
    JSTREE_IDX_INTOBJECT_REF,
    JSTREE_IDX_FLTOBJECT,
    JSTREE_IDX_FLTOBJECT_REF,
    JSTREE_IDX_RAWSTRING,
    JSTREE_IDX_STRING,
    JSTREE_IDX_STRING_REF,
    JSTREE_IDX_FUNCTION,
    JSTREE_IDX_FUNCTION_REF,
    JSTREE_IDX_ARRAY,
    JSTREE_IDX_ARRAY_REF,
    /* builtin function */
    JSTREE_IDX_NEW,
    JSTREE_IDX_NEW_INT,
    JSTREE_IDX_NEW_FLOAT,
    JSTREE_IDX_ARRAY_NEW,
    JSTREE_IDX_GETTER,
    JSTREE_IDX_SETTER,
    JSTREE_IDX_GET_PROTOTYPE,
    JSTREE_IDX_SET_PROTOTYPE,
    JSTREE_IDX_STRING_LENGTH,
    JSTREE_IDX_STATIC_STRING_NEW,
    JSTREE_IDX_FUNCTION_NEW,
    JSTREE_IDX_FUNCTION_CALL,
    JSTREE_MAX
};

extern tree js_global_trees[JSTREE_MAX];
#define js_init_node         (js_global_trees[JSTREE_IDX___INIT__])
#define call_entry_node      (js_global_trees[JSTREE_IDX_ENTRYPOINT])
#define abort_node           (js_global_trees[JSTREE_IDX_ABORT])
#define this_node            (js_global_trees[JSTREE_IDX_THIS])
#define integer_type_ptr     (js_global_trees[JSTREE_IDX_IPTR_TYPE])
#define object_type_node     (js_global_trees[JSTREE_IDX_OBJECT])
#define object_type_ptr      (js_global_trees[JSTREE_IDX_OBJECT_REF])
#define intobj_type_node     (js_global_trees[JSTREE_IDX_INTOBJECT])
#define intobj_type_ptr      (js_global_trees[JSTREE_IDX_INTOBJECT_REF])
#define floatobj_type_node   (js_global_trees[JSTREE_IDX_FLTOBJECT])
#define floatobj_type_ptr    (js_global_trees[JSTREE_IDX_FLTOBJECT_REF])
#define string_type_node     (js_global_trees[JSTREE_IDX_RAWSTRING])
#define obj_string_type_node (js_global_trees[JSTREE_IDX_STRING])
#define obj_string_type_ptr  (js_global_trees[JSTREE_IDX_STRING_REF])
#define function_type_node   (js_global_trees[JSTREE_IDX_FUNCTION])
#define function_type_ptr    (js_global_trees[JSTREE_IDX_FUNCTION_REF])
#define array_type_node      (js_global_trees[JSTREE_IDX_ARRAY])
#define array_type_ptr       (js_global_trees[JSTREE_IDX_ARRAY_REF])

#define new_node     (js_global_trees[JSTREE_IDX_NEW])
#define new_int_node    (js_global_trees[JSTREE_IDX_NEW_INT])
#define new_float_node  (js_global_trees[JSTREE_IDX_NEW_FLOAT])
#define getter_node  (js_global_trees[JSTREE_IDX_GETTER])
#define setter_node  (js_global_trees[JSTREE_IDX_SETTER])
#define get_prototype_node  (js_global_trees[JSTREE_IDX_GET_PROTOTYPE])
#define set_prototype_node  (js_global_trees[JSTREE_IDX_SET_PROTOTYPE])
#define string_length_node  (js_global_trees[JSTREE_IDX_STRING_LENGTH])
#define static_string_new_node  (js_global_trees[JSTREE_IDX_STATIC_STRING_NEW])
#define function_new_node  (js_global_trees[JSTREE_IDX_FUNCTION_NEW])
#define function_call_node (js_global_trees[JSTREE_IDX_FUNCTION_CALL])
#define array_new_node       (js_global_trees[JSTREE_IDX_ARRAY_NEW])

#endif /* end of include guard: JS_TREE_H */

